
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <!-- Basic Page Needs
    ================================================== -->
    <meta charset="utf-8">
    <title>Tell a Story</title>
    <!-- Favicons
    ================================================== -->
    <link rel="shortcut icon" href="${pageContext.request.contextPath}/res/img/favicon.ico" type="image/x-icon">
    <link rel="apple-touch-icon" href="${pageContext.request.contextPath}/res/img/apple-touch-icon.png">
    <link rel="apple-touch-icon" sizes="72x72" href="${pageContext.request.contextPath}/res/img/apple-touch-icon-72x72.png">
    <link rel="apple-touch-icon" sizes="114x114" href="${pageContext.request.contextPath}/res/img/apple-touch-icon-114x114.png">

    <!-- Bootstrap -->
    <link rel="stylesheet" type="text/css"  href="${pageContext.request.contextPath}/res/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/res/fonts/font-awesome/css/font-awesome.css">

    <!-- Nivo Lightbox
    ================================================== -->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/res/css/nivo-lightbox.css" >
    <link rel="stylesheet" href="${pageContext.request.contextPath}/res/css/nivo_lightbox_themes/default/default.css">

    <!-- Slider
    ================================================== -->
    <link href="${pageContext.request.contextPath}/res/css/owl.carousel.css" rel="stylesheet" media="screen">
    <link href="${pageContext.request.contextPath}/res/css/owl.theme.css" rel="stylesheet" media="screen">

    <!-- Stylesheet
    ================================================== -->
    <link rel="stylesheet" type="text/css"  href="${pageContext.request.contextPath}/res/css/style.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/res/css/responsive.css">


    <script type="text/javascript" src="${pageContext.request.contextPath}/res/js/modernizr.custom.js"></script>
    <script src="${pageContext.request.contextPath}/res/js/jquery-1.11.2.min.js"></script>
    <script src="${pageContext.request.contextPath}/res/js/bootstrap.js"></script>
    <script>
        var onPageNum;
        $(function(){
            onPageNum  =  1;
            var isSuccess= "${isSuccess}";
            console.log(isSuccess);
            if(isSuccess=="true"){
                $("#alertInfo").show();
                $("#alertInfo").text("删除成功");
                setTimeout(function(){$("#alertInfo").hide();},2000);
            }
            else if(isSuccess=="false"){
                $("#alertWrong").show();
                $("#alertWrong").text("删除失败");
                setTimeout(function(){$("#alertInfo").hide();},2000);
            }
            <% request.getSession().removeAttribute("isSuccess");%>
        });
        function deleteArticle(columnID,articleID) {
            $('#deleteColumnArticle').modal();
            $("#columnID").val(columnID);
            $("#articleID").val(articleID);
        }
        function page(goPage) {
            if(goPage=="next"){
                onPageNum = onPageNum+1;
            }
            else if(goPage=="prev"){
                if(onPageNum<=1) return ;
                else onPageNum = onPageNum-1;
            }
            var columnID = '${columnID}';
            var params = {
                columnID:columnID,
                pageNum : onPageNum,
                whatPage: "user"
            };
            $.ajax({
                type: "POST",
                url: "/columnArticle/goPage",
                data: params,
                dataType:"html", //ajax返回值设置为text（json格式也可用它返回，可打印出结果，也可设置成json）
                success: function(data){
                    var columnDTOList = $(data).find("#columnDTOList");

                    if(columnDTOList.html()!=null){
                        $("#column").empty();
                        $("#column").append(columnDTOList).html();
                    }
                    else{
                        onPageNum=onPageNum-1;
                    }
                },
                error: function(data){
                    alert("服务器错误! data="+data);
                    return false;
                }
            });
        }// end function page
    </script>
</head>
<body>
<!-- Main Navigation
================================================== -->

<jsp:include   page="../nav.jsp" flush="true"/>



<!--  Blog Section
================================================== -->
<div id="tf-blog" class="blog">
    <div class="container"> <!-- container -->
        <div class="section-header">
            <h2><strong>Blog</strong></h2>
            <h5><em></em></h5>
            <div class="fancy"><span><img src="${pageContext.request.contextPath}/res/img/favicon.ico" alt="..."></span></div>
        </div>
    </div>

    <div id="blog-post"> <!-- fullwidth gray background -->
        <div class="container"><!-- container -->

            <div class="row"> <!-- row -->
                <div class="col-md-6 col-md-offset-1"> <!-- Left Blogrol col 8 -->
                    <div id="column">
                        <c:if test="${columnArticleList==null}">
                            <h5 class="media-heading"><strong>你还没有在这个专栏发表任何文章！</strong></h5>
                        </c:if>
                        <c:forEach var="columnArticle" items="${columnArticleList}" varStatus="vs">
                            <div id="columnDTOList" class="post-wrap"> <!-- Post Wrapper -->
                                <div class="media post"> <!-- post wrap -->
                                    <div class="media-left">
                                    </div>
                                    <div class="media-body">
                                        <p class="small">${columnArticle.genTime}</p>
                                        <a href="/columnArticle/goColumnArticlePost?articleID=${columnArticle.articleID}">
                                            <h5 class="media-heading"><strong>${columnArticle.articleName}</strong></h5>
                                        </a>
                                        <p>${columnArticle.articleContent}</p>
                                    </div>
                                </div><!-- end post wrap -->

                                <div class="post-meta"> <!-- Meta details -->
                                    <ul class="list-inline metas pull-left"> <!-- post metas -->
                                        <li><a href="/columnArticle/goEditColumnArticle?articleID=${columnArticle.articleID}">编辑</a></li> <!-- meta comments -->
                                        <li><a href="" onclick="deleteArticle('${columnArticle.columnID}','${columnArticle.articleID}');return false" >删除</a></li>
                                    </ul>
                                    <ul class="list-inline meta-detail pull-right"> <!-- user meta interaction -->
                                        <li><i class="fa fa-eye"></i>${columnArticle.readNum}</li> <!-- no. of views -->
                                    </ul>
                                </div><!-- end Meta details -->
                            </div><!-- end Post Wrapper -->
                        </c:forEach>
                    </div>

                    <c:if test="${columnArticleList!=null}">
                        <div class="text-left"> <!-- Blogrol Pagination -->
                            <nav>
                                <ul class="pagination">
                                    <li>
                                        <a href="" aria-label="Previous" onclick="page('prev');return false">
                                            <span aria-hidden="true">Prev</span>
                                        </a>
                                    </li>

                                    <li>
                                        <a href="" aria-label="Next" onclick="page('next');return false">
                                            <span aria-hidden="true" >Next</span>
                                        </a>
                                    </li>
                                </ul>
                            </nav>
                        </div>
                    </c:if>

                </div> <!-- end Left content col 8 -->



            </div>

        </div><!-- end container -->
    </div> <!-- end fullwidth gray background -->
</div>

<!-- Footer
================================================== -->
<jsp:include   page="../foot.jsp" flush="true"/>



<!-- 删除专栏文章 模态框（Modal） -->
<div class="modal fade" id="deleteColumnArticle" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">操作提示</h4>
            </div>
            <div id="optionInfo" class="modal-body">确定要删除这篇文章？</div>
            <div id="buttons" class="modal-footer">
                <form action="/columnArticle/deleteColumnArticle" method="post">
                    <input id="columnID" name="columnID" type="hidden" />
                    <input id="articleID" name="articleID" type="hidden" />
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="submit" class="btn btn-primary">确定</button>
                </form>

            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>

</body>
</html>
